﻿using System;

namespace Sustainalytics.DataLayer
{
    public class RepositoryException : Exception
    {
        public RepositoryException(string dbname, string collection, string operation = "")
            : base(string.Format("{0}/{1}/{2}", dbname, collection, operation))
        {
            Database = dbname;
            Collection = collection;
            Operation = operation;
        }

        public override string Message
        {
            get { return string.Format("Database {0}, collection {1}, operation {2} failed.", Database, Collection, Operation); }
        }

        public string Operation { get; set; }
        public string Database { get; set; }
        public string Collection { get; set; }
    }

    public class RepositoryBulkException : RepositoryException
    {
        public RepositoryBulkException(string dbname, string collection)
            : base(dbname, collection, "Bulk")
        {
        }
    }

    public class RepositoryDropException : RepositoryException
    {
        public RepositoryDropException(string dbname, string collection)
            : base(dbname, collection, "Drop")
        {
        }
    }

    public class RepositoryRemoveAllException : RepositoryException
    {
        public RepositoryRemoveAllException(string dbname, string collection)
            : base(dbname, collection, "RemoveAll")
        {
        }
    }
}
